package t327.advice;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice//控制层的切面操作
public class ErrorAdvice {//异常处理
    @ExceptionHandler(Exception.class)//进行异常的捕获
    public ModelAndView handle(Exception e){//处理所有程序中的异常
        ModelAndView mv = new ModelAndView("error");//默认的处理路径
        mv.addObject("message",e.getMessage());//保存异常信息
        return mv;
    }
}
